# chstyle.tcl - style changing window
#
# CONTENTS:
#	chstyle
#		Shows a dialog with all Tile styles loaded
#		currently, waits for user input and changes
#		the application style. Takes no arguments

proc chstyle {} {
	global CONFIG
	
	if [winfo exists .chstyle] {
		return 1
	}
	
	global TTKSTYLE
	
	set styles [$TTKSTYLE theme names]

	toplevel .chstyle
	wm title .chstyle [tr "Change style"]
	pack [frame .chstyle.top]
	pack [set list [listbox .chstyle.top.options]]
	set idx 0
	
	foreach style $styles {
		$list insert end $style
		incr idx
	}
	
	pack [ttk::button .chstyle.btn -text [tr "Set"] -command {
		if {[.chstyle.top.options curselection] != {}} {
			set done 1
		}
	}]
	vwait done
	
	$TTKSTYLE theme use [$list get [$list curselection]]
	set CONFIG(widgetstyle) [$list get [$list curselection]]
	saveconfig
	
	destroy .chstyle
}
